import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/a.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/config.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class TemplateListItem extends StatelessWidget {
  final bool isSelect;
  final String url;
  final VoidCallback onWatch;
  final VoidCallback onSelect;

  TemplateListItem(
      {Key key, this.isSelect, this.url, this.onWatch, this.onSelect})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        PressedOpacityButton(
          onPressed: onSelect,
          child: Container(
            foregroundDecoration: isSelect == true
                ? BoxDecoration(
                    color: aceLightBlue.withOpacity(0.35),
                  )
                : null,
            alignment: Alignment.center,
            child: Image(
              image: Config.toImageProvider(url),
              fit: BoxFit.fitHeight,
            ),
          ),
        ),
        if (isSelect == true)
          Center(
            child: SvgPicture.asset(
              A.assetsImagesSettingCheckCircle,
              width: getDp(25),
              height: getDp(25),
            ),
          ),
        Positioned(
          bottom: getDp(11),
          right: getDp(12),
          child: PressedOpacityButton(
            onPressed: onWatch,
            child: SvgPicture.asset(
              A.assetsImagesSettingEye,
              width: getDp(21),
              height: getDp(21),
              fit: BoxFit.contain,
            ),
          ),
        ),
      ],
    );
  }
}
